<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Axios API Request</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <!-- 引入axios -->
</head>

<body>
    <h1>Axios API Request Example</h1>
    <button onclick="fetchData()">Fetch Data</button>
    <pre id="output"></pre>

    <script>
        async function fetchData() {
            let data = await getData()
            document.getElementById('output').textContent = JSON.stringify(data.data, null, 2);
        }
        async function getData() {
            return await axios.get('https://jsonplaceholder.typicode.com/posts')
        }
    </script>
</body>

</html>